﻿#pragma once


#include "Property/EditorPropertyModel.h"
#include "Pages/EditorPageModel.h"
#include "EditorReflectedPropertyModel.m.h"


RCLASS()
class REditorPropertyOperation : public REditorPageOperation
{
    ROBJECT

public:
    void ChangeValue(
        RObjectPtr InObject
        ,const TVector<CString> & InPropertyPath
        ,CAny InOldValue
        ,CAny InNewValue
    );

    void ChangeVirtualPropertyValue(
        RObjectPtr InObject
        ,CProperty* InProperty
        ,CAny InOldValue
        ,CAny InNewValue
    );

    TDelegate<void> OnUndoRedo;
protected:
    CAny OldValue;
    CAny NewValue;

    //字段属性相关：支持容器
    TVector<CString> PropertyPath;
    void* GetPropertyValue();
    void* GetPropertyValue(
        CType* InParentPropertyType
        , void* InParentPropertyValue
        , const TVector<CString>& InPropertyPath);

    //虚拟属性相关：
    CProperty* Property=nullptr;


};


RCLASS()
class REditorReflectedPropertyModel : public REditorPropertyModel
{
    ROBJECT

public:

    static TSharedObjectPtr<REditorReflectedPropertyModel> Create(
        TSharedObjectPtr<RObject> InValueObject
        ,RObject * InParent
    );

    RFIELD()
    TSharedObjectPtr<RObject> Object;
};
